package yto.freemarker.springcloud.configuration;

import feign.Contract;
import feign.Logger;
import feign.auth.BasicAuthRequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Feign的自定义的配置
 * @author dongxing
 * @create 2018-03-02 9:21
 **/
@Configuration
public class UserServiceConfiguration {

    /**
     * 将契约改为Feign的原生默认的契约，这样就可以使用Feign自带的注解了
     * @return
     */
    @Bean
    public Contract contract(){
        return new  feign.Contract.Default();
    }

    /**
     * Feign的日记级别
     * @return
     */
    @Bean
    Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }

    /**
     * 基于Http basic认证后才能调用的设置
     * @return
     */
    @Bean
    public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
        return new BasicAuthRequestInterceptor("user", "password123");
    }
}
